using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace NBusiness.CodeDom.Compiler
{
    [Serializable]
	public class EntityElement
	{
		#region Member fields and properties
		private EntityElementType _type = EntityElementType.Unknown;
		public EntityElementType Type
		{
			get { return _type; }
			set { _type = value; }
		}
		private string _value = null;

		public string Value
		{
			get { return _value; }
		}

		private int _line = -1;

		public int Line
		{
			get { return _line; }
			set { _line = value; }
		}
		private int _column = -1;

		public int Column
		{
			get { return _column; }
			set { _column = value; }
		}
        private int _beginoffset;

        public int BeginOffset
        {
            get { return _beginoffset; }
            set { _beginoffset = value; }
        }
        private int _endoffset;

        public int EndOffset
        {
            get { return _endoffset; }
            set { _endoffset = value; }
        }

		private string _path;

		public string Path
		{
			get { return _path; }
			set { _path = value; }
		}
		#endregion

		#region Constructors
		public EntityElement(string value, int line, int character, int beginOffset, int endOffset)
		{
			_value = value;
			_line = line;
			_column = character;
            _beginoffset = beginOffset;
            _endoffset = endOffset;
        }
        #endregion

        public override string ToString()
        {
            return string.Format("{0}: {1} [l{2},c{3},b{4},e{5}]",
                _type.ToString(),
                _value,
                _line,
                _column,
                _beginoffset,
                _endoffset);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            bool equals = false;
            if(obj is EntityElement)
            {
                EntityElement ee = obj as EntityElement;
                equals = Type == ee.Type && Value == ee.Value && Line == ee.Line && Column == ee.Column;
            }
            return equals;
        }
    }
}
